#pragma once
#include<iostream>
#include <list>  

class IObserver
{
public:
	virtual ~IObserver() {};
	virtual void Update(const std::string& newspapers) const = 0;
};

class Publisher
{
public:
	virtual ~Publisher()
	{
		std::cout << "Goodbye , I Was The Publisher." << std::endl;
	}

	void Subscribe(IObserver* observer);
	void UnSubscribe(IObserver* observer);

	void Notify();
	void Publish(std::string newspapers = "Empty");

private:
	std::list<IObserver*> list_Observer_;
	std::string newspaper_;
};

class Observer :public IObserver
{
private:
	Publisher * subject_;
	int number_;

public:
	Observer(Publisher* subject, int number) :subject_(subject), number_(number) {
		this->subject_->Subscribe(this);
		std::cout << "Hi I Am The Observer ! " << std::endl;
	}
	virtual ~Observer()
	{
		std::cout << "Goodbye, I Was The Observer !" << this->number_ << std::endl;
	}

	void Update(const std::string& newspapers) const override;
	void RemoveMeFromTheList();
};

